package my_account;

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;

import org.testng.*;
import org.testng.annotations.*;

import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

public class View_all_tags extends ru.st.selenium.pages.TestBase {
  private boolean acceptNextAlert = true;
  private StringBuffer verificationErrors = new StringBuffer();

    @Test
  public void testUntitled7() throws Exception {
	/*driver.get(baseUrl);
    driver.findElement(By.linkText("My Account")).click();
    driver.findElement(By.id("email")).clear();
    driver.findElement(By.id("email")).sendKeys("qatestingtestqa@gmail.com");
    driver.findElement(By.id("pass")).clear();
    driver.findElement(By.id("pass")).sendKeys("qwerty");
    driver.findElement(By.id("send2")).click();*/
    	driver.get(baseUrl + "/customer/account/");
    try {
      assertEquals("My Recent Tags", driver.findElement(By.cssSelector("div.box-account.box-tags > div.box-head > h2")).getText());
    } catch (Error e) {
      verificationErrors.append(e.toString());
    }
    try {
      assertEquals("View All Tags", driver.findElement(By.linkText("View All Tags")).getText());
    } catch (Error e) {
      verificationErrors.append(e.toString());
    }
    driver.findElement(By.linkText("View All Tags")).click();
    try {
      assertEquals("My Tags", driver.findElement(By.cssSelector("h1")).getText());
    } catch (Error e) {
      verificationErrors.append(e.toString());
    }
    try {
      assertEquals("Click on a tag to view your corresponding products.", driver.findElement(By.cssSelector("div.my-account > p")).getText());
    } catch (Error e) {
      verificationErrors.append(e.toString());
    }
    try {
        assertEquals("Test", driver.findElement(By.linkText("Test")).getText());
      } catch (Error e) {
        verificationErrors.append(e.toString());
      }
      driver.findElement(By.linkText("Test")).click();
      try {
        assertEquals("Ottoman", driver.findElement(By.linkText("Ottoman")).getText());
      } catch (Error e) {
        verificationErrors.append(e.toString());
      }
      driver.findElement(By.linkText("Ottoman")).click();
      try {
        assertEquals("Test", driver.findElement(By.linkText("Test")).getText());
      } catch (Error e) {
        verificationErrors.append(e.toString());
      }
  }

   private boolean isElementPresent(By by) {
    try {
      driver.findElement(by);
      return true;
    } catch (NoSuchElementException e) {
      return false;
    }
  }

  
  private String closeAlertAndGetItsText() {
    try {
      Alert alert = driver.switchTo().alert();
      String alertText = alert.getText();
      if (acceptNextAlert) {
        alert.accept();
      } else {
        alert.dismiss();
      }
      return alertText;
    } finally {
      acceptNextAlert = true;
    }
  }
}
